home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Utilities / Winter Shell 1.0d2 / Source / Libraries / VolumeLib / VolumeLib.c next >
Encoding:
C/C++ Source or Header  |  1993-12-08  |  1.6 KB  |  68 lines  |  [TEXT/KAHL]

  1. /* Functions for getting information about a volume.
  2.  
  3.     93/10/16 aih
  4.     - added VolNameType
  5.     
  6.     93/03/10 AIH
  7.     - Added check for support for FSSpec calls to check for FSpExchangeFiles
  8.     
  9.     91/07/03 AIH
  10.     - Added function to return free space on a volume
  11.     
  12.     91/06/01 AIH
  13.     - Added function to test whether a volume supports the desktop manager
  14.     
  15.     91/05/27 Ari Halberstadt (AIH)
  16.     - Created this file */
  17.  
  18. #include <string.h>
  19. #include "MacLib.h"
  20. #include "VolumeLib.h"
  21.  
  22. /* get a volume parameter block */
  23. void VolumeParameters(VolType vol, GetVolParmsInfoBuffer *params)
  24. {
  25.     HParamBlockRec pb;
  26.     
  27.     memclr(&pb, sizeof(HParamBlockRec));
  28.     pb.ioParam.ioVRefNum = vol;
  29.     pb.ioParam.ioBuffer = (Ptr) params;
  30.     pb.ioParam.ioReqCount = sizeof(GetVolParmsInfoBuffer);
  31.     FailOSErr(PBHGetVolParms(&pb, false));
  32. }
  33.  
  34. /* true if the volume supports file IDs, as described in IM-VI */
  35. Boolean VolumeSupportsFileIDs(VolType vol)
  36. {
  37.     GetVolParmsInfoBuffer params;
  38.     
  39.     VolumeParameters(vol, ¶ms);
  40.     return((params.vMAttrib & bHasFileIDs) != 0);
  41. }
  42.  
  43. /* true if the volume supports the FSpExchangeFiles routine */
  44. Boolean VolumeSupportsFSpExchangeFiles(VolType vol)
  45. {
  46.     return(MacHasFSSpec() && VolumeSupportsFileIDs(vol));
  47. }
  48.  
  49. /* true if the volume has a desktop database */
  50. Boolean VolumeSupportsDesktopMgr(VolType vol)
  51. {
  52.     GetVolParmsInfoBuffer params;
  53.     
  54.     VolumeParameters(vol, ¶ms);
  55.     return((params.vMAttrib & bHasDesktopMgr) != 0);
  56. }
  57.  
  58. /* return free space */
  59. size_t VolumeFree(VolType vol)
  60. {
  61.     HParamBlockRec pb;
  62.     
  63.     memclr(&pb, sizeof(HParamBlockRec));
  64.     pb.volumeParam.ioVRefNum = vol;
  65.     FailOSErr(PBHGetVInfo(&pb, false));
  66.     return(pb.volumeParam.ioVFrBlk * pb.volumeParam.ioVAlBlkSiz);
  67. }
  68.